# Maintainer: Christoph Reiter <reiter.christoph@gmail.com>

_realname=setuptools-scm
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python2-${_realname}" "${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=2.0.0
pkgrel=1
pkgdesc='Handles managing your python package versions in scm metadata (mingw-w64)'
url='https://github.com/pypa/setuptools_scm'
license=('MIT')
arch=('any')
makedepends=("${MINGW_PACKAGE_PREFIX}-python2"
             "${MINGW_PACKAGE_PREFIX}-python3"
             "${MINGW_PACKAGE_PREFIX}-python2-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python3-setuptools"
            )
source=("https://pypi.org/packages/source/${_realname::1}/${_realname}/${_realname/-/_}-${pkgver}.tar.gz")
sha256sums=('638627655ec4625b7a055a5b65f44e88121fce05a281a1597abd6a9f8c04139b')

prepare() {
  cd "${srcdir}"
}

package_python3-setuptools-scm() {
  depends=("${MINGW_PACKAGE_PREFIX}-python3-setuptools")
  cd "${srcdir}"

  cp -r "${_realname/-/_}-${pkgver}" "python3-build-${CARCH}"
  cd ${srcdir}/python3-build-${CARCH}
  ${MINGW_PREFIX}/bin/python3 setup.py build
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python3 setup.py install --prefix="${MINGW_PREFIX}" --root="${pkgdir}" -O1
}

package_python2-setuptools-scm() {
  depends=("${MINGW_PACKAGE_PREFIX}-python2-setuptools")
  cd "${srcdir}"

  cp -r "${_realname/-/_}-${pkgver}" "python2-build-${CARCH}"
  cd ${srcdir}/python2-build-${CARCH}
  ${MINGW_PREFIX}/bin/python2 setup.py build
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python2 setup.py install --prefix="${MINGW_PREFIX}" --root="${pkgdir}" -O1
}

package_mingw-w64-i686-python2-setuptools-scm() {
  package_python2-setuptools-scm
}

package_mingw-w64-i686-python3-setuptools-scm() {
  package_python3-setuptools-scm
}

package_mingw-w64-x86_64-python2-setuptools-scm() {
  package_python2-setuptools-scm
}

package_mingw-w64-x86_64-python3-setuptools-scm() {
  package_python3-setuptools-scm
}
